<template>
  <div>
    <div class="right">
      <a href="javascript:void (0)" v-routers="{path:'/'}"></a>
    </div>
    <div class="card">
      <el-input style="width: 260px;margin-right: 10px" placeholder="请输入用户名称"></el-input>
      <el-button class="defaultBtn" icon="el-icon-search" color="#333" type="info">查询</el-button>
      <el-button class="defaultBtn" icon="el-icon-refresh-right"  type="info">重置</el-button>
    </div>
    <div class="card">
      <el-button @click="dialogVisible=true" class="defaultBtn" icon="el-icon-plus"  type="info">新增</el-button>
    </div>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="name" label="用户名称" min-width="180"></el-table-column>
      <el-table-column prop="class" label="班级名称" min-width="180"></el-table-column>
      <el-table-column prop="major" label="专业名称" min-width="180"></el-table-column>
      <el-table-column prop="type" label="用户类型" min-width="180">
        <template #default="{row}">{{type(row)}}</template>
      </el-table-column>
      <el-table-column prop="crateTime" label="创建时间" min-width="180"></el-table-column>
      <el-table-column fixed="right" align="center" label="操作" width="180">
        <el-button size="mini" class="defaultBtn" type="info">删除</el-button>
        <el-button size="mini" class="defaultBtn" type="info">编辑</el-button>
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
    </div>



    <el-dialog title="用户信息" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户类型">
          <el-radio-group v-model="form.resource">
            <el-radio :label="0">学生</el-radio>
            <el-radio :label="1">辅导员</el-radio>
            <el-radio :label="2">老师</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="用户账号">
          <el-input v-model="form.name" placeholder="请输入账号名称"></el-input>
        </el-form-item>
        <el-form-item label="用户密码">
          <el-input v-model="form.name" placeholder="请输入密码" type="password"></el-input>
        </el-form-item>
        <el-form-item label="专业名称">
          <el-input v-model="form.name" placeholder="请输入专业名称"></el-input>
        </el-form-item>
        <el-form-item label="班级名称" v-if="form.resource===0">
          <el-select v-model="form.region" style="width: 100%;" placeholder="请选择班级名称">
            <el-option label="计算机科学技术一班" value="1"></el-option>
            <el-option label="计算机科学技术二班" value="2"></el-option>
            <el-option label="计算机科学技术三班" value="3"></el-option>
            <el-option label="计算机科学技术四班" value="4"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消创建</el-button>
        <el-button type="info" class="defaultBtn" @click="onSubmit" >立即创建</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible:false,
      tableData: [{name:'张三丰',class:'计算机科学与网络3班',major:'计算机科学与网络',type:0,crateTime:'2022-12-31 12:00:00'}],
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: 0,
        desc: ''
      }
    }
  },
  methods:{
    type(item){
      console.log(item)
      switch (item.type){
        case 0:{
          return '学生'
        }
        case 1:{
          return  '辅导员'
        }
        case 2:{
          return '教师'
        }
      }
    },
    handleClose(){
      this.dialogVisible=false
    },
    onSubmit() {
      console.log('submit!');
      this.dialogVisible=false
    }
  }
}
</script>

<style scoped lang="scss">

.card{
  width: 100%;
  margin: 10px 0;
}
.page{
  width: 100%;
  display: flex;
  justify-content: right;
  margin-top: 10px;
}
::v-deep(.el-pagination.is-background .el-pager li:not(.disabled).active ){
  background: #333 !important;
  color: #fff;
}
</style>
